package org.rea.GUI;

import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.JButton;
import javax.swing.JPanel;

public class TabPane extends JPanel implements ActionListener{

	private JButton _btnInsert, _btnModify, _btnView, _btnDelete;
	private final String tableName;
	
	
	public TabPane(final String tableName) {
		this.tableName = tableName;
		_btnModify = new JButton("Modifica");
		_btnInsert = new JButton("Inserisci");
		_btnView = new JButton("Visualizza");
		_btnDelete = new JButton("Cancella");
		

		_btnView.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println(tableName);
			}
		});

		_btnInsert.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				//System.out.println(tableName);
				try {
					new InsertNew(tableName).setVisible(true);
					
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});

		_btnModify.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println(tableName);
				
			}
		});
		
		_btnDelete.addActionListener(new ActionListener() {

			@Override	
			public void actionPerformed(ActionEvent e) {
				System.out.println(tableName);
			}
		});

		this.setLayout(new GridLayout(2,2));
		add(_btnInsert);
		add(_btnModify);
		add(_btnDelete);
		add(_btnView);
		


	}

	public void stocazzo(ActionEvent e){

	}


	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub

	}


}
